<template>
  <div class="jgldmk">
    <div class="blueTitleStyle">光字牌</div>
    <div class="content startbox">
      <div
        class="btn centerbox"
        v-for="(item,index) in newGzpData"
        :key="index"
        @click="handel(item)"
        :class="{active:item.active}"
      >{{item.deviceName}}</div>
    </div>
    <el-dialog
      :title="PopUpdata.deviceName+setPopUpTitle+'历史记录'"
      :visible.sync="dialogVisible"
      width="70%"
      :before-close="handleClose"
    >
      <PopUp :PopUpdata="PopUpdata" @Title="Title" v-if="dialogVisible" />
      <iframe class="iframe" frameborder="0"></iframe>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { GetSocketModule } from "@/store/modules/GetSocketData";
import PopUp from "./PopUp.vue";

@Component({
  components: { PopUp },
})
export default class extends Vue {
  mounted() {
    this.gzp(this.$route.query.BAYID);
  }
  PopUpdata = {};
  PopUpTitle = "";
  get setPopUpTitle() {
    return this.PopUpTitle;
  }
  //弹框状态
  dialogVisible = false;
  handleClose() {
    this.dialogVisible = false;
    this.PopUpTitle = "";
  }
  handel(item) {
    this.newGzpData.map((item) => {
      item.active = false;
    });
    this.dialogVisible = true;
    this.PopUpdata = item;
  }
  Title(val) {
    this.PopUpTitle = val;
  }
  gzpData = [];
  gzp(id) {
    var params: any = {
      bayId: id,
    };
    (this as any).$services
      .onlineMonitorqueryLinkage({ data: params })
      .then((result: any) => {
        let data = result.data || [];
        this.gzpData = data;
      })
      .catch((err: object) => {
        console.log(err);
      });
  }
  get newGzpData() {
    let gzpData = this.gzpData;
    gzpData.map((item, index) => {
      var is = false;
      if (GetSocketModule.AllAuxiliaryByDeviceId[item.deviceId]) {
        var state = GetSocketModule.AllAuxiliaryByDeviceId[
          item.deviceId
        ].filter((item) => {
          // 非遥信和告警
          return item.remoteType !== "2" && item.isGj == "gj";
        });
        if (state.length > 0) {
          is = true;
        }
      } else {
        is = false;
      }
      gzpData[index].active = is;
      gzpData[index].gjxxArr = state;
    });
    return gzpData;
  }
}
</script>

<style lang="scss" scoped>
.jgldmk {
  width: 100%;
  height: 100%;
  .content {
    width: 100%;
    height: calc(100% - 0.3rem);
    padding: 0.1rem 0.2rem;
    box-sizing: border-box;
    flex-wrap: wrap;
    overflow: auto;
    .btn {
      height: 0.5rem;
      width: calc(50% - 0.1rem);
      border: 2px solid #1489c9;
      background-color: rgba(29, 103, 103, 0.4);
      font-size: 0.14rem;
      padding: 0.04rem 0.1rem;
      cursor: pointer;
      margin-right: 0.1rem;
      margin-bottom: 0.06rem;
    }
    .active {
      background: linear-gradient(to top, #b22222, #dc143c);
    }
  }
  .iframe {
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0px;
    left: 0px;
    z-index: 1;
    opacity: 0.1;
    background: none;
    pointer-events: none;
  }
}
</style>

